using System;
using System.Data;

using SqlHelperForCry.Common;

namespace Torch.WL.Entity
{
    [Table("Tb_Sys_Groups", "GroupID", "Torch.WL.ConnectionString")]
	public class Tb_Sys_Groups : Info
	{
		#region SQL column name consts 
		public const string SQLCOL_GROUPID = "GroupID";
		public const string SQLCOL_GROUPNAME = "GroupName";
		public const string SQLCOL_GROUPORDER = "GroupOrder";
		public const string SQLCOL_GROUPDESCRIPTION = "GroupDescription";
		public const string SQLCOL_GROUPTYPE = "GroupType";
		#endregion


		#region Contructors
		/// <summary>
		/// Construct empty entity
		/// </summary>
		public Tb_Sys_Groups () {}

		/// <summary>
		/// Construct entity by primary key, other fields will be assigned by 
		/// "Load" method.
		/// </summary>
		public Tb_Sys_Groups (int GroupID)
		{
			this.GroupID = GroupID;
		}
		#endregion

		public override void Init (DataRow row)
		{
			GroupID = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_GROUPID]);
			GroupName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_GROUPNAME]);
			GroupOrder = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_GROUPORDER]);
			GroupDescription = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_GROUPDESCRIPTION]);
			GroupType = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_GROUPTYPE]);
		}

		#region Properties 
		#region Property <int> GroupID
		[Property("GroupID", 4, SqlDbType.Int, true, true)]
		public int GroupID 
		{
			get { return _GroupID; }
			set { _GroupID = value; }
		}
		private int _GroupID = int.MinValue;
		#endregion

		#region Property <string> GroupName
		[Property("GroupName", 60, SqlDbType.NVarChar, false, false)]
		public string GroupName 
		{
			get { return _GroupName; }
			set { _GroupName = value; }
		}
		private string _GroupName = null;
		#endregion

		#region Property <int> GroupOrder
		[Property("GroupOrder", 4, SqlDbType.Int, false, false)]
		public int GroupOrder 
		{
			get { return _GroupOrder; }
			set { _GroupOrder = value; }
		}
		private int _GroupOrder = int.MinValue;
		#endregion

		#region Property <string> GroupDescription
		[Property("GroupDescription", 100, SqlDbType.NVarChar, false, false)]
		public string GroupDescription 
		{
			get { return _GroupDescription; }
			set { _GroupDescription = value; }
		}
		private string _GroupDescription = null;
		#endregion

		#region Property <int> GroupType
		[Property("GroupType", 4, SqlDbType.Int, false, false)]
		public int GroupType 
		{
			get { return _GroupType; }
			set { _GroupType = value; }
		}
		private int _GroupType = int.MinValue;
		#endregion
		#endregion


		public bool LoadByIdentity(int GroupID)
		{
			return DataAccess.SelectByIdentity(this, Convert.ToInt64(GroupID));
		}


		public bool DeleteByIdentity()
		{
			return DataAccess.DeleteByIdentity(this);
		}
	}
}
